package com.example.user.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.admin_model.dto.EmployeeDTO;
import com.example.user.service.UserService;
import com.example.user_model.dto.UserDTO;
import com.example.user_model.entity.User;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @author: sjz
 * @since: 2024/7/10 22:06
 */
@Slf4j
@RestController
@RequestMapping("/userApi")
public class UserApi {

    @Resource
    private UserService userService;

    @PostMapping("validate")
    public String validate(@RequestBody UserDTO userDTO) {
        String id = userService.validate(userDTO.getToken());
        return id;
    }

    @PostMapping("/getOne")
    public User getOne(LambdaQueryWrapper<User> wrapper) {
        return userService.getOne(wrapper);
    }
//    @PostMapping("/id")
//    public User getUser(String id){
//        return userService.getById(id);
//    }

    @GetMapping("/id")
    public User getById(@RequestParam("id") String id) {
        return userService.getById(id);
    }
}
